package com.tian.controller.api;

import com.tian.common.CommonResult;
import com.tian.dto.BaseRespPageDto;
import com.tian.dto.ChargeCouponApiRespDto;
import com.tian.dto.ChargeCouponPageReqDto;
import com.tian.dto.coupon.CheckCouponReqDto;
import com.tian.dto.coupon.CheckCouponRespDto;
import com.tian.service.ChargeCouponService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiResponse;
import io.swagger.annotations.ApiResponses;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import java.util.List;

/**
 * {@code @description:} 优惠券列表 控制器
 *
 * @author tianwc 公众号：Java后端技术全栈
 * 在线刷题 1200+java面试题和1000+篇技术文章：<a href="https://woaijava.cc/">博客地址</a>
 * {@code @date:} 2024-11-18 8:50
 * {@code @version:} 1.0
 */
@RestController
@RequestMapping("/api/coupon")
@Api(tags = "优惠券列表 控制器")
public class ChargeCouponApiController {
    @Resource
    private ChargeCouponService chargeCouponService;

    @ApiOperation(value = "优惠券列表", notes = "优惠券列表")
    @ApiResponses({@ApiResponse(code = 200000, message = "操作成功")})
    @PostMapping("/page")
    public CommonResult<BaseRespPageDto<List<ChargeCouponApiRespDto>>> list(@RequestBody ChargeCouponPageReqDto chargeCouponListReqDto) {
        return chargeCouponService.pageApi(chargeCouponListReqDto);
    }

    @ApiOperation(value = "优惠券校验", notes = "优惠券详情")
    @ApiResponses({@ApiResponse(code = 200000, message = "操作成功")})
    @PostMapping("/check")
    public CommonResult<CheckCouponRespDto> checkCoupon(@RequestBody CheckCouponReqDto checkCouponReqDto) {
        return chargeCouponService.checkCoupon(checkCouponReqDto);
    }
}
